require "Common/define"
require "Logic/Config"
require "Common/functions"

RedDotsCrossTeamRewardHandler = {}
local this = RedDotsCrossTeamRewardHandler;
function RedDotsCrossTeamRewardHandler.init()
    CloseEvent(Config.EventType.Fresh_CrossTeamRewardPreview, this.update)
    ListenEvent(Config.EventType.Fresh_CrossTeamRewardPreview, this.update)
    return this
end

--参数1： id，nil检查所有
function RedDotsCrossTeamRewardHandler.getFlag()  
    if logicMgr.FuncOpenManager.isOpen(Config.FuncOpenType.CrossTeamArena, false) then
        local data = logicMgr.ArenaManager.GetCrossTeamNewDuanWeiAward()
        if data ~= nil then
            for _, v in pairs(data) do
                if v and tostring(v) == "1" then
                    return Config.RedDotsFlagState.Needful 
                end
            end
        end
    end
    return Config.RedDotsFlagState.None
end

function RedDotsCrossTeamRewardHandler.update()
    RedDotsManager.addBroadcast(Config.RedDotsType.CrossTeamRewardPreview)
end
